package com.hongye.controller;

import java.util.List;

import com.hongye.app.model.BuyerStatisticsModel;
import com.hongye.app.model.Real_nameModel;
import com.hongye.util.PushUtils;
import com.jfinal.core.Controller;

public class Real_nameController extends Controller{
	
    public Real_nameController() {
		
	}
    
    /**
     * 列表展示
     * @author liushaomin
     * 2017年5月5日
     */
    public void realnameView(){
		List<Real_nameModel> list = Real_nameModel.getRealNameList();
		this.setAttr("realnamelist", list);
		this.renderJsp("realnameView.jsp");
	}
    
    /**
     * 认证信息详情页面
     * @author liushaomin
     * 2017年5月5日
     */
    public void realnameDetail(){
    	String id = this.getPara("id");
    	Real_nameModel realname = Real_nameModel.getRealNameBackstage(id);
		this.setAttr("realnameDetail", realname);
		this.setAttr("id", realname.get("id"));
		this.renderJsp("realnameDetail.jsp");
	}
    
    /**
     * 修改审核状态
     * @author liushaomin
     * 2017年5月5日
     */
    public void finisRealName(){
		String id = this.getPara("id");
		String state = this.getPara("state");
		String phone = this.getPara("phone");
		boolean boo = Real_nameModel.update_state(id, state);
		String rs= "fal";
		if(boo){
			rs = "suc";
			if(state.equals("3")){
				BuyerStatisticsModel buyer = BuyerStatisticsModel.getStatistics(phone);
				buyer.set("isrealname", 1).update();
				PushUtils.MSG_Single(phone, "D02", "您的实名认证已通过，去看看吧！");
			}else{
				PushUtils.MSG_Single(phone, "D02", "您的实名认证未通过，请修改后重新提交！");
			}
		}
		this.renderText(rs);
	}

}
